import json,os
# import pymongo


# client = pymongo.MongoClient('localhost', 27017)
# db = client.get_database('率士之滨')
# collection = db.get_collection('率士之滨')

import requests
# 爬取英雄图片
# hero_url = f'https://g0.gph.netease.com/ngsocial/community/stzb/cfg/hero_extra.json?gameid=g10'
# hero_response =  requests.get(hero_url)
# hero_data = hero_response.json()
# # print(hero_response.status_code)
# # print(hero_data)
# if not os.path.exists("率土之滨"):
#     os.mkdir("率土之滨")
# for item in hero_data:
#     # print(item.get("id"),item.get("name"))
#     hero_id_url = f"https://g0.gph.netease.com/ngsocial/community/stzb/cn/cards/cut/card_small_{item.get('id')}.jpg?gameid=g10"
#     hero_id_response = requests.get(hero_id_url)
#     with open(f"率土之滨/{item.get('name')}.jpg",'wb')as f:
#         f.write(hero_id_response.content)


# 爬取武器图片
# weapon_url = f'https://g0.gph.netease.com/ngsocial/community/stzb/cfg/gear_id.json?gameid=g10'
# weapon_response =  requests.get(weapon_url)
# # print(weapon_response.status_code)
# # print(weapon_response.json())
# weapon_data = weapon_response.json()
# if not os.path.exists("率土之滨武器库"):
#     os.mkdir("率土之滨武器库")
#
# for item in weapon_data:
#     weapon_id_url = f"https://g0.gph.netease.com/ngsocial/community/stzb/cn/gears/watermark/gear_watermark_{item.get('id')}.jpg"
#     weapon_id_response = requests.get(weapon_id_url)
#     print(item.get("id"),item.get("name"))
#     with open(f"率土之滨武器库/{item.get('name')}.jpg",'wb')as f:
#         f.write(weapon_id_response.content)

# 爬取功法库
ability_url = f'https://g0.gph.netease.com/ngsocial/community/stzb/cfg/skill_extra.json?gameid=g10'
abiliity_response = requests.get(ability_url)
print(abiliity_response.status_code)
print(abiliity_response.json())